- breadcrumb_title _("Advanced Search")
- page_title _("Advanced Search")
- add_page_specific_style 'page_bundles/settings'
- add_page_specific_style 'page_bundles/search'
- @force_desktop_expanded_sidebar = true

- help_link_start = "<a class='gl-link' href='#{help_page_path('integration/advanced_search/elasticsearch')}#%{anchor}' target='_blank' rel='noopener noreferrer'>"
- help_zero_downtime_reindexing_link_start = help_link_start.html_safe % { anchor: "zero-downtime-reindexing" }
- help_advanced_search_migrations_link_start = help_link_start.html_safe % { anchor: "advanced-search-migrations" }
- help_troubleshooting_link_start = "<a class='gl-link' href='#{help_page_path('integration/advanced_search/elasticsearch_troubleshooting')}#%{anchor}' target='_blank' rel='noopener noreferrer'>"
- help_recreate_index_link_start = help_troubleshooting_link_start.html_safe % { anchor: "last-resort-to-recreate-an-index" }

- if @search_error_if_version_incompatible
  - content_for :page_level_alert do
    %div{ class: [container_class, @content_class, 'gl-pt-5!'] }
      = render Pajamas::AlertComponent.new(title: s_('AdvancedSearch|Elasticsearch version not compatible'),
        dismissible: false,
        variant: :danger) do |c|
        - c.with_body do
          = s_('AdvancedSearch|Pause indexing and upgrade Elasticsearch to a supported version.')
          = link_to _('Learn more.'), help_page_path('integration/advanced_search/elasticsearch', anchor: 'version-requirements')

- if @search_outdated_code_analyzer_detected
  - content_for :page_level_alert do
    %div{ class: [container_class, @content_class, 'gl-pt-5!'] }
      = render Pajamas::AlertComponent.new(title: s_('AdvancedSearch|Reindex recommended'),
        dismissible: false,
        variant: :warning) do |c|
        - c.with_body do
          = s_('AdvancedSearch|You are using outdated code search mappings. To improve code search quality, we recommend you use %{reindexing_link_start}zero-downtime reindexing%{link_end} or %{recreate_link_start}re-create your index%{link_end}.').html_safe % { reindexing_link_start: help_zero_downtime_reindexing_link_start, recreate_link_start: help_recreate_index_link_start, link_end: '</a>'.html_safe }

- if @elasticsearch_warn_if_not_using_aliases
  - content_for :page_level_alert do
    %div{ class: [container_class, @content_class, 'gl-pt-5!'] }
      = render Pajamas::AlertComponent.new(title: s_('AdvancedSearch|Reindex required'),
        dismissible: false,
        variant: :warning) do |c|
        - c.with_body do
          = s_('AdvancedSearch|Introduced in GitLab 13.1, before using %{reindexing_link_start}zero-downtime reindexing%{link_end} and %{migrations_link_start}Advanced Search migrations%{link_end}, you need to %{recreate_link_start}recreate your index%{link_end}.').html_safe % { reindexing_link_start: help_zero_downtime_reindexing_link_start, migrations_link_start: help_advanced_search_migrations_link_start, recreate_link_start: help_recreate_index_link_start, link_end: '</a>'.html_safe }

- if @elasticsearch_pending_obsolete_migrations.any?
  - content_for :page_level_alert do
    %div{ class: [container_class, @content_class, 'gl-pt-5!'] }
      = render Pajamas::AlertComponent.new(title: s_('AdvancedSearch|You have pending obsolete migrations'),
        dismissible: false,
        variant: :danger) do |c|
        - c.with_body do
          = s_('AdvancedSearch|You have %{count} pending %{migrations_link_start}advanced search migrations%{link_end} that are obsolete. These migrations might affect your search experience. To resolve the issue, you must %{recreate_link_start}recreate your index%{link_end}.').html_safe % { count: @elasticsearch_pending_obsolete_migrations.count, migrations_link_start: help_advanced_search_migrations_link_start, recreate_link_start: help_recreate_index_link_start, link_end: '</a>'.html_safe }

= render_if_exists 'admin/application_settings/elasticsearch_form'
